<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:include href="../../admin.xsl" />
	<xsl:include href="../../common/form.xsl" />
	<xsl:include href="../../cp/path.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/admin/forms.css" type="text/css" media="all" />
		</head>
		<body>
			<xsl:call-template name="admin-header" />
			
			<div id="blocks">
				<div id="blocks_inner" />
			</div>
			
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<!-- SCALAR -->
	<xsl:template match="response[@character-type='scalar']">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;types')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:call-template name="type-title" />
			<xsl:if test="$method = 'add_field'">
				<xsl:text>Новое скалярное поле</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_field'">
				<xsl:text>Редактирование поля</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_field/{@type-id}/save?type={@character-type}" method="post">
			<xsl:if test="$method = 'edit_field'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_field/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates select="form/field[@name='field_name']" />
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:apply-templates select="form/field[@name='character']" mode="scalar" />
			<xsl:apply-templates select="form/field[@name='maxlength']" />
			<xsl:apply-templates select="form/field[@name='required']" mode="scalar" />
			<xsl:call-template name="default-value">
				<xsl:with-param name="defaultValue" select="sql/default" />
				<xsl:with-param name="isFieldRequired" select="form/field[@name='required']/value" />
			</xsl:call-template>
			<xsl:apply-templates select="form/field[@name='error']" />
			<xsl:apply-templates select="form/field[@name='editable']" />
			<xsl:apply-templates select="form/field[@name='help']" />
			<xsl:apply-templates select="form/field[@name='allow_search']" />
			
			<p>
				<input type="submit">
					<xsl:attribute name="value">
						<xsl:if test="$method = 'add_field'">
							<xsl:text>Добавить поле</xsl:text>
						</xsl:if>
						<xsl:if test="$method = 'edit_field'">
							<xsl:text>Сохранить</xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
			</p>
		</form>
		
		<p>
			<strong>Внимание! </strong>
			<xsl:text>Изменение свойств некоторых полей может привести к неработоспособности системы.</xsl:text>
		</p>
		
		<script type="text/javascript">
			<![CDATA[
				function disableDefValue (obj) {
					if(obj.checked) {
						document.getElementById('field_default').disabled = true;
						document.getElementById('field_default_null').disabled = true;
					} else {
						document.getElementById('field_default').disabled = false;
						document.getElementById('field_default_null').disabled = false;
					}
				}
				
				function disableDefNull (obj) {
					if (obj.value == '') {
						document.getElementById('field_default_null').checked = true;
					} else {
						document.getElementById('field_default_null').checked = false;
					}
				}
			]]>
		</script>
	</xsl:template>
	
	<!-- GUIDE -->
	<xsl:template match="response[@character-type='guide']">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;types')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:call-template name="type-title" />
			<xsl:if test="$method = 'add_field'">
				<xsl:text>Новое поле-спавочник</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_field'">
				<xsl:text>Редактирование поля</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_field/{@type-id}/save?type={@character-type}" method="post">
			<xsl:if test="$method = 'edit_field'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_field/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			
			<xsl:apply-templates select="form/field[@name='character']" mode="guide" />
			<xsl:apply-templates select="form/field[@name='field_name']" />
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:call-template name="guides-list">
				<xsl:with-param name="this" select="form/field[@name='additional_id']" />
			</xsl:call-template>
			<xsl:apply-templates select="form/field[@name='required']" />
			<xsl:apply-templates select="form/field[@name='error']" />
			<xsl:apply-templates select="form/field[@name='editable']" />
			<xsl:apply-templates select="form/field[@name='help']" />
			<xsl:apply-templates select="form/field[@name='allow_search']" />
			
			<p>
				<input type="submit">
					<xsl:attribute name="value">
						<xsl:if test="$method = 'add_field'">
							<xsl:text>Добавить поле</xsl:text>
						</xsl:if>
						<xsl:if test="$method = 'edit_field'">
							<xsl:text>Сохранить</xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
			</p>
		</form>
		
		<p>
			<strong>Внимание! </strong>
			<xsl:text>Изменение свойств некоторых полей может привести к неработоспособности системы.</xsl:text>
		</p>
	</xsl:template>
	
	<!-- TAGS -->
	<xsl:template match="response[@character-type='tags']">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;types')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:call-template name="type-title" />
			<xsl:if test="$method = 'add_field'">
				<xsl:text>Новое тег-поле</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_field'">
				<xsl:text>Редактирование поля</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_field/{@type-id}/save?type={@character-type}" method="post">
			<xsl:if test="$method = 'edit_field'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_field/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			
			<input type="hidden" name="data[{$formPrefix}][character]" value="tags" />
			
			<xsl:apply-templates select="form/field[@name='field_name']" />
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:apply-templates select="form/field[@name='required']" />
			<xsl:apply-templates select="form/field[@name='error']" />
			<xsl:apply-templates select="form/field[@name='editable']" />
			<xsl:apply-templates select="form/field[@name='help']" />
			<xsl:apply-templates select="form/field[@name='allow_search']" />
			
			<p>
				<input type="submit">
					<xsl:attribute name="value">
						<xsl:if test="$method = 'add_field'">
							<xsl:text>Добавить поле</xsl:text>
						</xsl:if>
						<xsl:if test="$method = 'edit_field'">
							<xsl:text>Сохранить</xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
			</p>
		</form>
		
		<p>
			<strong>Внимание! </strong>
			<xsl:text>Изменение свойств некоторых полей может привести к неработоспособности системы.</xsl:text>
		</p>
	</xsl:template>
	
	<!-- IMAGE -->
	<xsl:template match="response[@character-type='image']">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;types')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:call-template name="type-title" />
			<xsl:if test="$method = 'add_field'">
				<xsl:text>Новое поле-изображение</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_field'">
				<xsl:text>Редактирование поля</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_field/{@type-id}/save?type={@character-type}" method="post">
			<xsl:if test="$method = 'edit_field'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_field/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			
			<input type="hidden" name="data[{$formPrefix}][character]" value="image" />
			
			<xsl:apply-templates select="form/field[@name='field_name']" />
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:call-template name="images-profiles">
				<xsl:with-param name="this" select="form/field[@name='additional_id']" />
				<!--xsl:with-param name="selected" select="form/field[@name='additional_id']/value" />
				<xsl:with-param name="error" select="form/field[@name='additional_id']/error" /-->
			</xsl:call-template>
			<xsl:apply-templates select="form/field[@name='required']" />
			<xsl:apply-templates select="form/field[@name='error']" />
			<xsl:apply-templates select="form/field[@name='editable']" />
			<xsl:apply-templates select="form/field[@name='help']" />
			<xsl:apply-templates select="form/field[@name='allow_search']" />
			
			<p>
				<input type="submit">
					<xsl:attribute name="value">
						<xsl:if test="$method = 'add_field'">
							<xsl:text>Добавить поле</xsl:text>
						</xsl:if>
						<xsl:if test="$method = 'edit_field'">
							<xsl:text>Сохранить</xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
			</p>
		</form>
		
		<p>
			<strong>Внимание! </strong>
			<xsl:text>Изменение свойств некоторых полей может привести к неработоспособности системы.</xsl:text>
		</p>
	</xsl:template>
	
	<!-- CONNECTED -->
	<xsl:template match="response[@character-type='connected']">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;system;types')/data/response" mode="cp-path">
				<xsl:with-param name="activeLink">1</xsl:with-param>
			</xsl:apply-templates>
		</div>
		
		<h1>
			<xsl:call-template name="type-title" />
			<xsl:if test="$method = 'add_field'">
				<xsl:text>Новое связанное поле</xsl:text>
			</xsl:if>
			<xsl:if test="$method = 'edit_field'">
				<xsl:text>Редактирование поля</xsl:text>
			</xsl:if>
		</h1>
		
		<form action="{$baseURI}/admin/system/add_field/{@type-id}/save?type={@character-type}" method="post">
			<xsl:if test="$method = 'edit_field'">
				<xsl:attribute name="action">
					<xsl:value-of select="concat($baseURI, '/admin/system/edit_field/', $formPrefix, '/save')" />
				</xsl:attribute>
			</xsl:if>
			
			<input type="hidden" name="data[{$formPrefix}][character]" value="object_value" />
			
			<xsl:apply-templates select="form/field[@name='field_name']" />
			<xsl:apply-templates select="form/field[@name='title']" />
			<xsl:call-template name="connection">
				<xsl:with-param name="typeId" select="@type-id" />
				<xsl:with-param name="connection" select="form/field[@name='connection_id']" />
				<xsl:with-param name="field" select="form/field[@name='additional_id']" />
			</xsl:call-template>
			<xsl:apply-templates select="form/field[@name='allow_search']" />
			
			<p>
				<input type="submit">
					<xsl:attribute name="value">
						<xsl:if test="$method = 'add_field'">
							<xsl:text>Добавить поле</xsl:text>
						</xsl:if>
						<xsl:if test="$method = 'edit_field'">
							<xsl:text>Сохранить</xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
			</p>
		</form>
		
		<script type="text/javascript">
			<xsl:text disable-output-escaping="yes">
				function reloadFields (connection, type) {
					$.ajax ({
						url: baseURI + '/admin/system/ajax_type_fields_connection/?connection=' + connection + '&amp;type=' + type,
						dataType: 'xml',
						type: 'get',
						error: function() { alert('Произошла ошибка!') },
						success: function(xml) {
							$('#connected_field option[value!=0]').remove();
							
							var fields = $(xml).find('field').each (function() {
								$("&lt;option&gt;&lt;/option&gt;")
									.attr('value', $(this).find('id').text())
									.text($(this).find('title').text())
									.appendTo('#connected_field');
							});
							
							$('#connected_field').attr('disabled',false);
						}
					});
				}
			</xsl:text>
		</script>
		
		<p>
			<strong>Внимание! </strong>
			<xsl:text>Изменение свойств некоторых полей может привести к неработоспособности системы.</xsl:text>
		</p>
	</xsl:template>
	
	<xsl:template name="type-title">
		<xsl:param name="oType" select="document(concat('xobject://explay_type/', @type-id))/data/object" />
		
		<a href="{$baseURI}/admin/system/fields/{@type-id}">
			<xsl:value-of select="$oType/property[@name='title']/value" />
		</a>
		<xsl:text>: </xsl:text>
	</xsl:template>
	
	<xsl:template name="connection">
		<xsl:param name="typeId" />
		<xsl:param name="connection" />
		<xsl:param name="field" />
		<xsl:param name="connectionId" select="$connection/value" />
		<xsl:param name="conFieldId" select="$field/value" />
		
		<div class="form_field">
			<div class="form_field_label">
				<xsl:text>Подсасываемое поле:</xsl:text>
			</div>
			<div class="form_field_input">
				<select id="connected_field_type" class="form_input_select" name="data[{$formPrefix}][connection_id]" onchange="reloadFields(this.value,{$typeId})">
					<option value="0">-- выберите связь с типом данных</option>
					
					<xsl:for-each select="document(concat('xmodule://system/getTypesConnections/', $typeId))/data/response/object">
						<option>
							<xsl:attribute name="value">
								<xsl:value-of select="@id" />
							</xsl:attribute>
							<xsl:if test="$connectionId = @id">
								<xsl:attribute name="selected">
									<xsl:text>selected</xsl:text>
								</xsl:attribute>
							</xsl:if>
							
							<xsl:value-of select="concat(@parent-type-title, ' (', @parent-field-title, ') → ', @child-type-title, ' (', @child-field-title, ')')" />
						</option>
					</xsl:for-each>
				</select>
				
				<xsl:text> </xsl:text>
				
				<select id="connected_field" class="form_input_select" name="data[{$formPrefix}][additional_id]">
					<xsl:if test="$conFieldId = ''">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
					</xsl:if>
					
					<option value="0">-- выберите поле</option>
					
					<xsl:if test="$conFieldId != ''">
						<xsl:for-each select="document(concat('xmodule://system/getTypeFieldsByOne/', $conFieldId))/data/response/object">
							<option>
								<xsl:attribute name="value">
									<xsl:value-of select="@id" />
								</xsl:attribute>
								<xsl:if test="$conFieldId = @id">
									<xsl:attribute name="selected">
										<xsl:text>selected</xsl:text>
									</xsl:attribute>
								</xsl:if>
								
								<xsl:value-of select="property[@name='title']/value" />
							</option>
						</xsl:for-each>
					</xsl:if>
				</select>
				
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template name="images-profiles">
		<xsl:param name="this" />
		<!--xsl:param name="selected" />
		<xsl:param name="error" /-->
		
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{$this/@id}">
					<xsl:text>Профиль изображений:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{$this/@id}" class="form_input_select" name="data[{$formPrefix}][{$this/@name}]">
					<option value="0">-- выберите</option>
					<xsl:for-each select="document('xmodule://system/getImagesProfiles')/data/response/object">
						<option>
							<xsl:attribute name="value">
								<xsl:value-of select="@id" />
							</xsl:attribute>
							<xsl:if test="$this/value = @id">
								<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
							</xsl:if>
							<xsl:value-of select="property[@name='title']/value" />
						</option>
					</xsl:for-each>
				</select>
				<xsl:if test="$this/error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="$this/error" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template name="guides-list">
		<xsl:param name="this" />
		
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{$this/@id}">
					<xsl:text>Тип объектов осправочника:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{$this/@id}" class="form_input_select" name="data[{$formPrefix}][{$this/@name}]">
					<option value="0">-- выберите</option>
					<xsl:for-each select="document('xmodule://system/getGuides')/data/response/object">
						<option>
							<xsl:attribute name="value">
								<xsl:value-of select="@id" />
							</xsl:attribute>
							<xsl:if test="$this/value = @id">
								<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
							</xsl:if>
							<xsl:value-of select="@guide-type-title" />
						</option>
					</xsl:for-each>
				</select>
				<xsl:if test="$this/error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="$this/error" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="form/field[@name='character']" mode="guide">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:text>Тип справочника:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{@id}" class="form_input_select" name="data[{$formPrefix}][{@name}]">
					<option value="guide">
						<xsl:if test="value = 'guide'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>с возможностью выбора одного значение</xsl:text>
					</option>
					<option value="multiguide">
						<xsl:if test="value = 'multiguide'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>с возможностью выбора нескольких значений</xsl:text>
					</option>
				</select>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="form/field[@name='required']" mode="scalar">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:value-of select="title" />
					<xsl:text>: </xsl:text>
				</label>
				<input id="field_{@id}" type="checkbox" value="1" name="data[{$formPrefix}][{@name}]" onchange="disableDefValue(this);">
					<xsl:if test="value = '1'">
						<xsl:attribute name="checked">
							<xsl:text>checked</xsl:text>
						</xsl:attribute>
					</xsl:if>
				</input>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template name="default-value">
		<xsl:param name="defaultValue" />
		<xsl:param name="isFieldRequired" />
		
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_default">
					<xsl:text>Значение по умолчанию:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<input id="field_default" class="form_input_text" type="text" name="default_value" onblur="disableDefNull(this);">
					<xsl:if test="number($isFieldRequired) = 1">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
					</xsl:if>
					<xsl:attribute name="value">
						<xsl:if test="$defaultValue != 'NULL'">
							<xsl:value-of select="$defaultValue" />
						</xsl:if>
						<xsl:if test="$defaultValue = 'NULL'">
							<xsl:text></xsl:text>
						</xsl:if>
					</xsl:attribute>
				</input>
				<div>
					<label for="field_default_null">
						<xsl:text>NULL: </xsl:text>
					</label>
					<input id="field_default_null" type="checkbox" name="default_value_null" value="1">
						<xsl:if test="number($isFieldRequired) = 1">
							<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:if test="$defaultValue = 'NULL'">
							<xsl:attribute name="checked"><xsl:text>checked</xsl:text></xsl:attribute>
						</xsl:if>
					</input>
				</div>
			</div>			
		</div>
	</xsl:template>
	
	<xsl:template match="form/field[@name='field_name']">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:value-of select="title" />
					<xsl:text>:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<input id="field_{@id}" class="form_input_text" type="text" name="data[{$formPrefix}][{@name}]">
					<!--xsl:if test="$method = 'edit_field'">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
					</xsl:if-->
					<xsl:attribute name="value">
						<xsl:value-of select="value" />
					</xsl:attribute>
				</input>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="form/field[@name='character']" mode="scalar">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:value-of select="title" />
					<xsl:text>:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{@id}" class="form_input_select" type="text" name="data[{$formPrefix}][{@name}]">
					<xsl:if test="$method = 'edit_field'">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
					</xsl:if>
					<option value="header">
						<xsl:if test="value = 'header'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Заголовок</xsl:text>
					</option>
					<option value="latin">
						<xsl:if test="value = 'latin'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Латиница</xsl:text>
					</option>
					<option value="integer">
						<xsl:if test="value = 'integer'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Целое число</xsl:text>
					</option>
					<option value="text">
						<xsl:if test="value = 'text'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Текст</xsl:text>
					</option>
					<option value="boolean">
						<xsl:if test="value = 'boolean'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Флажок</xsl:text>
					</option>
					<option value="email">
						<xsl:if test="value = 'email'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>E-mail</xsl:text>
					</option>
					<option value="date">
						<xsl:if test="value = 'date'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Дата</xsl:text>
					</option>
					<option value="float">
						<xsl:if test="value = 'float'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Дробное число</xsl:text>
					</option>
					<option value="birthdate">
						<xsl:if test="value = 'birthdate'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>Число (дата)</xsl:text>
					</option>
				</select>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>